﻿// ===============================================================================
// XCI.NET 西安交通信息WinForm开发框架 2018 版权所有
// ===============================================================================
using System;
using System.Windows.Forms;

namespace XCI.Windows
{
    /// <summary>
    /// 隐藏启动程序
    /// </summary>
    public class HideOnStartupApplicationContext : ApplicationContext
    {
        /// <summary>
        /// 构造函数，主窗体被存储在mainFormInternal
        /// </summary>
        /// <param name="mainForm">主窗体</param>
        public HideOnStartupApplicationContext(Form mainForm)
        {
            var mainFormInternal = mainForm;
            mainFormInternal.Closed += mainFormInternal_Closed;
        }

        /// <summary>
        /// 当主窗体被关闭时，退出应用程序
        /// </summary>
        void mainFormInternal_Closed(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}